#ifndef OBJECTS_TEXTOBJECT_H
#define OBJECTS_TEXTOBJECT_H

#include <QtCore/qobject.h>
#include <QtGui/qcolor.h>
#include <QtGui/qfont.h>

#include "../doker.h"

QT_FORWARD_DECLARE_CLASS(QScriptEngine)

class TextObject : public QObject
{
    Q_OBJECT
    Q_PROPERTY(qreal x READ x WRITE setX)
    Q_PROPERTY(qreal y READ y WRITE setY)
    Q_PROPERTY(qreal width READ width WRITE setWidth)
    Q_PROPERTY(qreal w READ width WRITE setWidth)
    Q_PROPERTY(qreal height READ height WRITE setHeight)
    Q_PROPERTY(qreal h READ height WRITE setHeight)
    Q_PROPERTY(qreal size READ size WRITE setSize)
    Q_PROPERTY(QString alignment READ alignment WRITE setAlignment)
    Q_PROPERTY(QString align READ alignment WRITE setAlignment)
    //Q_PROPERTY(QString color READ color WRITE setColor)
    Q_PROPERTY(QString rgb READ rgb WRITE setRgb)
    Q_PROPERTY(QString cmyk READ cmyk WRITE setCmyk)
    Q_PROPERTY(int alpha READ alpha WRITE setAlpha)

public:

    explicit TextObject(const QString &content, QObject *parent = 0);

    void linkToSource(const QString &fileName, int lineNumber)
    { m_sourceFileName = fileName; m_sourceLineNumber = lineNumber; }

    qreal width() const { return m_width; }
    void setWidth(qreal w) { m_width = w; }
    qreal height() const { return m_height; }
    void setHeight(qreal h) { m_height = h; }

    QString content() { return m_content; }
    qreal x() const { return m_x; }
    void setX(qreal x) { m_x = x; }
    int pixelX() {return toPixels(m_x); }
    qreal y() const { return m_y; }
    void setY(qreal y) { m_y = y; }
    int pixelY() {return toPixels(m_y); }

    qreal size() const;
    void setSize(qreal s);

    QString alignment() const;
    void setAlignment(const QString &align);
    Qt::Alignment alignmentFlags() const { return m_alignment; }

    //QString color() const;
    //void setColor(const QString &color);
    QString rgb() const;
    void setRgb(const QString &rgb);
    QString cmyk() const;
    void setCmyk(const QString &cmyk);
    int alpha() const { return m_color.alpha(); }
    void setAlpha(int alpha) { m_color.setAlpha(alpha); }
    const QColor &color() const { return m_color; }


    const QFont &font() const { return m_font; }

private:
    QString          m_sourceFileName;
    int              m_sourceLineNumber;

    QString          m_content;
    qreal            m_width;
    qreal            m_height;
    QFont            m_font;

    qreal            m_x;
    qreal            m_y;

    Qt::Alignment    m_alignment;
    QColor           m_color;

};

#endif // OBJECTS_TEXTOBJECT_H
